﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using EShop.DAL;
using EShop.Common;

namespace EShop.BLL
{
    public class ShopReportBLL
    {

        ShopReportDAL oShopReportDAL = new ShopReportDAL();

        public void DailySelledReport(DateTime Day,out decimal Saleroom,out DataTable SelledDetail, string EmployeeID)
        {
            DataSet ds = oShopReportDAL.DailySelledReport(Day, EmployeeID);
            try
            {
                Saleroom = Convert.ToDecimal(FormatManager.FormatDecimal(Convert.ToDecimal(ds.Tables[0].Rows[0][0])));
            }
            catch { Saleroom = 0m; }
            SelledDetail = ds.Tables[1];
        }

        /// <summary>
        /// 返回指定日期有销售记录的员工
        /// </summary>
        /// <param name="selledDate">指定日期</param>
        /// <returns></returns>
        public Dictionary<object, object> GetSelledEmployee(DateTime selledDate)
        {
            return oShopReportDAL.GetSelledEmployee(selledDate);
        }

        /// <summary>
        /// 获取日趋势图数据
        /// </summary>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public DataTable GetTrendChartByDay(DateTime beginDate, DateTime endDate)
        {
            return oShopReportDAL.GetTrendChart(0,beginDate, endDate);
        }

        /// <summary>
        /// 获取月趋势图数据
        /// </summary>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public DataTable GetTrendChartByMonth(DateTime beginDate, DateTime endDate)
        {
            return oShopReportDAL.GetTrendChart(1, beginDate, endDate);
        }

        /// <summary>
        /// 获取指定时间段内商品的销售数量
        /// </summary>
        /// <param name="beginDate"></param>
        /// <param name="endDate"></param>
        /// <returns></returns>
        public DataTable GetHotMerchandise(DateTime beginDate, DateTime endDate)
        {
            return oShopReportDAL.GetHotMerchandise(beginDate, endDate);
        }

         /// <summary>
        /// 查询利润
        /// </summary>
        /// <param name="iType">
        /// 0，按年份查看利润
        /// 1，按月份查看利润
        /// 2，按日期查看利润
        /// 3，查看某单号的具体详情
        /// </param>
        /// <param name="strYear">年份yyyy</param>
        /// <param name="strMonth">月份MM</param>
        /// <param name="strDay">日期dd</param>
        /// <param name="strOrderID">OrderID</param>
        /// <returns></returns>
        public DataTable GetProfits(int iType, string strYear, string strMonth, string strDay, string strOrderID)
        {
            return oShopReportDAL.GetProfits(iType, strYear, strMonth, strDay, strOrderID);
        }
    }
}
